Repository navigation
fix(security): Reject DSN hosts that requests would send elsewhere - #164
Merged
Merged
Conversation
Co-Authored-By: Armen Zambrano Gasparnian <44410+armenzg@users.noreply.github.com>
sentry-junior
Bot
force-pushed
the
fix/dsn-host-backslash-bypass
branch
from
November 9, 2026 14:52
34f220e to
1c86995
Compare
armenzg
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Category: application security (SSRF / unsafe outbound requests).
#153 made
GithubClientonly post envelopes tosentry.iohosts over HTTPS. That check can be bypassed with a backslash in the DSN host, so an org can still point the app's envelope requests at any HTTPS host.The vulnerability
The check reads the host with
urlsplit(throughsentry_sdk.utils.Dsn), which keeps a\in the host. requests (urllib3) treats\as the start of the path. With a DSN likehttps://key@evil.example\.sentry.io/1:Dsn(...).hostisevil.example\.sentry.io, which ends in.sentry.io, so the check passes.sentry_project_urlishttps://evil.example\.sentry.io/api/1/envelope/. requests prepares it ashttps://evil.example/%5C.sentry.io/api/1/envelope/and connects toevil.example.I reproduced this on
mainwith the locked requests 2.34.2 and urllib3 2.8.0. The DSN comes fromsentry_config.iniin the org's.sentryrepo, and any org that installs the GitHub App controls that file.Severity
Medium. This is a bypass of an existing control, and it gives a blind SSRF: any org that installs the app can make the Cloud Run service POST gzipped envelopes to a host or IP of its choice on port 443. That includes internal addresses the service can reach and third-party hosts, with the app's egress IP as the source. The request carries the org's own CI data and its own DSN public key. GitHub tokens never go to this URL, so no tokens or other orgs' data leak.
Production evidence
f950db04e5d44c739338508b09c01e09(revisiongithub-actions-app-00044-kpl, Nov 5) is aConnectTimeoutfrom_send_envelopeposting to a non-Sentry host. That was before fix(security): Only send envelopes to Sentry DSN hosts over HTTPS #153.github-actions-app-00047-rz8) runs the fix(security): Only send envelopes to Sentry DSN hosts over HTTPS #153 check. In event52a56be16cf84efc910ae4afcba26b41, thesend_trace/_send_envelopeline numbers matchmain. This bypass gets around that check.Fix
The host now has to fully match
(?:[a-z0-9-]+\.)*sentry\.io:sentry.ioor a subdomain whose labels only hold letters, digits, and hyphens.urlsplitlowercases the host, so there's no case to handle. Valid DSNs (o1.ingest.us.sentry.io,sentry.io:8443) are still accepted. Rejected DSNs raiseBadDsn, which the handler already reports as an invalid org config (200,invalid_dsnmetric).Verification
test_initialize_with_invalid_dsn, with and without a port. They fail onmain("DID NOT RAISE BadDsn") and pass with this change.uv run pytest(95 passed),uv run mypy, anduv run pre-commit run --all-filesall pass.Draft #89 also touches DSN validation, but it's based on the code from before #153 and doesn't handle this case.
via automation
sched_2663accc24a4cb8adfb43de4543ec71e· Run IDsched_2663accc24a4cb8adfb43de4543ec71e:1794227400000.--
View Session [Sentry]